module.exports = function(grunt) {
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),
		meta: {
			srcPath: 'build/source/css-sass/',			
			deployPath: 'build/dist/css/'
		},

		banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + 
				'<%= grunt.template.today("yyyy-mm-dd") %>\n' + 
				'* Copyright (c) <%= grunt.template.today("yyyy") %> ',

		sass: {
			dist: {
				options: {
					sourcemap: 'auto',
					style: 'expanded'
				},
				files: [{
					expand: true,
					cwd: '<%= meta.srcPath %>',
					src: ['basic_*.scss', 'util_*.scss'],
					dest: '<%= meta.deployPath %>',
					ext: '.css'
				}]
			},
			dist_min: {
				options: {
					sourcemap: 'auto',
					style: 'compressed'
				},
				files: [{
					expand: true,
					cwd: '<%= meta.srcPath %>',
					src: ['basic_*.scss', 'util_*.scss'],
					dest: '<%= meta.deployPath %>',
					ext: '.min.css'
				}]
			},
			pack: {  // 所有打包到一起
				options: {
					sourcemap: 'auto',
					style: 'expanded'
				},
				files: {
					'<%= meta.deployPath %>bsui_all.css': 'build/source/bsui_all.scss'
				}
			},
			pack_min: {  // 打包压缩
				options: {
					sourcemap: 'auto',
					style: 'compressed'
				},
				files: {
					'<%= meta.deployPath %>bsui_all.min.css': 'build/source/bsui_all.scss'
				}
			}
		},

		autoprefixer: {
			options: {
				browsers: ['last 10 versions', '> 5%', 'ie 9']  // 浏览器兼容
			},
			css: {
				// 目标文件
				src: [
					'<%= meta.deployPath %>/*.css'
				]
			}
		}

		// watch: {
		// 	scripts: {
		// 		files: ['<%= meta.srcPath %>*.scss'],
		// 		tasks: ['sass:dist']
		// 	}
		// }
	}); 

	grunt.loadNpmTasks('grunt-contrib-sass'); 
	grunt.loadNpmTasks('grunt-contrib-watch');
	grunt.loadNpmTasks('grunt-autoprefixer');
	// Default task. 
	grunt.registerTask('dist', ['sass:dist', 'autoprefixer:css']);
	grunt.registerTask('dist_min', ['sass:dist_min', 'autoprefixer:css']);
	grunt.registerTask('pack', ['sass:pack', 'autoprefixer:css']);
	grunt.registerTask('pack_min', ['sass:pack_min', 'autoprefixer:css']);
};